﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>

<body>
    <h5>供应商密码</h5>
    <div class="form-body">
        <div class="form-horizontal  hide" id="form">

        </div>
    </div>
</body>
</html>
<script type="text/html" id="tp-form">
    <div class="form-group">
        <label class="col-sm-2">用户id</label>
        <div class="col-md-6 col-sm-10">
            <input type="text" class="form-control" data-form="Id" placeholder="用户id" value="{{Id}}" maxlength="16">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2">密码</label>
        <div class="col-md-6 col-sm-10">
            <input type="text" class="form-control" data-form="Pwd" placeholder="密码" value="{{Pwd}}"  maxlength="18">
        </div>
    </div>
    
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" id="btn-submit" class="btn btn-primary">保存</button>
            <button type="button" class="btn" onclick="window.history.go(-1)">退出</button>
        </div>
    </div>
</script>
<link href="/script/valid/css/tr.css" rel="stylesheet" /><!--判断如：PlatformName格式-->
<script src="/script/valid/form-valid.js?v=2018"></script>
<script>  
    $(function () {
        var id = QueryPageUrlString("v");
        console.log()
        var formValidEvent;
        var formValidInit = function () {
            var formValidData = [
                {
                    key: "Id",
                    datatype: "*",
                    nullmsg: "不能为空哦",
                    errormsg: "不能为空哦"
                },
                {
                    key: "Pwd",
                    datatype: "*",
                    nullmsg: "不能为空哦",
                    errormsg: "不能为空哦"
                },
            ];
            formValidEvent = $(".form-body").formValid(formValidData);
        }
        var inintData = {
            Id: id,
            Pwd: "",
        };   
        $("#form").templateRender({ el: "tp-form", data: inintData });//渲染模板，要先渲染才能获值
        formValidInit();

        $("#form").on("click", "#btn-submit", function () { //保存按钮有添加和编辑
            if (!formValidEvent.check()) { return; }
            var apiUrl = "supplier/updpwd";
            $("#form").ajaxFormSubmit(apiUrl, {
                pass: function (d) {
                    $.msgSucceed(d.Errmsg);
                    return
                },
                error: function (d) {
                    console.log(d)
                    $.msgFall(d.Errmsg);
                }
            })
            return
        });
    });
   
</script>
